Skip to content

Reviewing and refining generator and testing code - #327

Merged
rijesha merged 1 commit into
developfrom
copilot/review-generator-boilerplate-testing
May 30, 2026
Merged

Reviewing and refining generator and testing code#327
rijesha merged 1 commit into
developfrom
copilot/review-generator-boilerplate-testing

Conversation

Copilot AI commented May 30, 2026

Copy link
Copy Markdown
Contributor

Pull request created by AI Agent

…minator enum helpers, shared _check, cross-reference comments

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is an internal cleanup/refactor across the generators and test suite. It centralizes a duplicated _check(condition, msg) helper into tests/test_utils.py, factors the field-order discriminator enum generation into shared helpers in src/struct_frame/base.py (consumed by C/C#/JS/Python/TypeScript generators), corrects a copy-paste bug where leading message comments were assigned instead of accumulated (result = ...result += ...) in C/JS/TS/Python generators, tightens C/C++ round-trip test gating in tests/run_tests.py to require an explicit successful compilation result, and adds twin-maintenance notes plus a small simplification to the JS/TS GenericFrameParser.getInitialState().

Changes:

  • Centralize _check into tests/test_utils.py and replace duplicated copies in 7 test files.
  • Introduce get_discriminator_enum_name / build_discriminator_enum_values shared helpers and refactor C/C#/JS/Python/TS discriminator enum generation; fix message-comment accumulation (+=) in those generators.
  • Gate C/C++ round-trip tests on compilation.get(lang, False); add JS/TS twin-maintenance comments and simplify getInitialState().

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_utils.py New shared _check helper module.
tests/test_caching.py, test_equality.py, test_magic_bytes.py, test_no_packed.py, test_proto_field_types.py, test_validate_flag.py, test_wire_evolution.py Remove local _check, import shared helper.
tests/run_tests.py Require explicit successful compilation result for C/C++ round-trip phases (default flipped from True to False).
src/struct_frame/base.py Add get_discriminator_enum_name and build_discriminator_enum_values helpers.
src/struct_frame/init.py Export the new helpers.
src/struct_frame/c_gen.py Use shared discriminator helpers; fix message-comment accumulation.
src/struct_frame/csharp_gen.py Use shared discriminator helpers (output unchanged).
src/struct_frame/js_gen.py Use shared discriminator helpers; fix message-comment accumulation in two generators.
src/struct_frame/py_gen.py Use shared discriminator helpers; fix message-comment accumulation.
src/struct_frame/ts_gen.py Use shared discriminator helpers; fix message-comment accumulation in two generators.
src/struct_frame/boilerplate/ts/frame-base.ts Simplify getInitialState() (remove redundant branch); add twin-maintenance note.
src/struct_frame/boilerplate/js/frame-base.js Add twin-maintenance note.

Comment thread tests/test_caching.py
import os
import subprocess
import sys
from test_utils import _check
@rijesha
rijesha merged commit 8d08149 into develop May 30, 2026
24 checks passed
@rijesha
rijesha deleted the copilot/review-generator-boilerplate-testing branch May 30, 2026 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants